const fs=require('fs');
const path=require('path');
const root=process.cwd();
export function exists(src){
    return fs.existsSync(src);
}

export function readFile(src){
    return fs.readFileSync(src);
}

export function writeFile(src,data){
    fs.writeFileSync(src,data);
}

export function filePath(savefileId){
    let name='';
    if (savefileId < 0) {
        name = 'config.rpgsave';
    } else if (savefileId == 0) {
        name = 'global.rpgsave';
    } else {
        name = `file${savefileId}.rpgsave`;
    }
    return path.join(root,'save',name);
}

export function remove(src){
    fs.unlinkSync(src);
}